This resource address creates a new alert configuration. You can use the
uri
parameter and the add-alert-triggers
operation to add the
triggers specified in the alert configuration to an existing alert configuration. You can use
the uri
parameter and the remove-alert-triggers
operation to remove
the triggers from an existing alert configuration. New alert configurations are done on the
content database.
Upon success, MarkLogic Server returns status code 202 (Accepted). If the alert already exists or if the payload is malformed, a status code of 400 (Bad Request) is returned. A status code of 401 (Unauthorized) is returned if the user does not have the necessary privileges.
manage-admin
rolehttp://marklogic.com/xdmp/privileges/manage-admin
http://marklogic.com/xdmp/privileges/manage
privilege, plus one of the following privileges:
http://marklogic.com/xdmp/privileges/admin/database
http://marklogic.com/xdmp/privileges/admin/database/database-ID
http://marklogic.com/xdmp/privileges/admin/database/alerts/database-ID
The structure of the data in a create alert request is as shown below.
Note: The properties described here are for XML payloads. In general they are the same for
JSON, with the exception that, in JSON, triggers
, domains
,
actions
, and options
are expressed in singular form.
id
uri
name
description
triggers
This is a complex structure with the following children:
trigger
domains
This is a complex structure with the following children:
domain
options
This is a complex structure with the following children:
option
actions
This is a complex structure with the following children:
action
The structure of the data in an add-alert-triggers request is as shown below. This operation adds the triggers specified in the alert configuration.
{"operation": "add-alert-triggers"}
The structure of the data in an remove-alert-triggers request is as shown below. This operation removes all triggers associated with the alert.
{"operation": "remove-alert-triggers"}
curl -X POST --anyauth --user admin:admin --header "Content-Type:application/json" \ -d '{ "uri": "my-alert-config", "name": "My Alerting App", "description": "Alerting config for my app", "trigger": [], "domain": [], "action": [], "option": [] }' \ http://localhost:8002/manage/v2/databases/Documents/alert/configs ==> Creates a new alert, named "My Alerting App," for the Documents database.
curl -X POST --anyauth --user admin:admin --header "Content-Type:application/json" \ -d '{"operation": "add-alert-triggers"}' \ http://localhost:8002/manage/v2/databases/Documents/alert/configs?uri=my-alert-config ==> Adds a new trigger for the 'my-alert-config' alert to the Documents database.